﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PEUtility
{
    public static class ToModel
    {
        public static TModel DataRowToModel<TModel>(this DataRow dr)
        {
            Type type = typeof(TModel);
            Activator.CreateInstance(type);
            TModel model = (TModel)Activator.CreateInstance(type);
            foreach (var prop in type.GetProperties())
            {
                prop.SetValue(model, dr[prop.Name]);
            } 
            return model;
        }
    } 
}
